{extends file="../home.html"}
{block name="title"}{$head_title}{/block}
{block name="css"}
<link rel="stylesheet" style="text/css" href="__PUBLIC__/Css/front/user_glb.css?version={$version}">
{/block}
{block name="content"}
{include file="$header_path"}
	<div id="container" style="height:300px;">地图</div>
	<!--主内容-->
	<div class="edit_addr_cont">
		<!--地址编辑区-->
	</div>
{/block}
{block name="js"}
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=8904f42a99f576207303619b99e50d52"></script>
<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script> 
<script type="text/javascript" src="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
<link rel="stylesheet" href="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.css" />
<script>
{literal}
	//var map = new BMap.Map("container");
	var map;
	var point;
	var geolocation = new BMap.Geolocation();
	var gc = new BMap.Geocoder();
	var loationFlag = 0;
	geolocation.getCurrentPosition(function(r) {
          if (this.getStatus() == BMAP_STATUS_SUCCESS) {
              var pt = r.point;
              var message = "";
              gc.getLocation(pt,function(rs) {
                  var addComp = rs.addressComponents;
				  console.log(pt);
				  console.log(rs);
                  //var address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber;
                  var address = addComp.city + addComp.district + addComp.street + addComp.streetNumber;
                  console.log(address);
                  $('#pos_text').html("<em>猜您在：</em>" + address);
                  loationFlag = 1;                  
									$("#positionBtn").click(function(){
						         //window.location.href = "/FrontMall/mall_list";
						      });                  									
              });
          } else {
              $("#pos_text").html("定位失败");
              $("#positionBtn").click(function() {
				          $("#pos_text").html("定位获取中...");
				          gpsLocation();
				      });
          }
      }, getPositionError); //定位 
	function translatePoint(position)
	{
		var currentLat = position.coords.latitude; 
		var currentLon = position.coords.longitude; 
		var gpsPoint = new BMap.Point(currentLon, currentLat); 
		BMap.Convertor.translate(gpsPoint, 0, initMap); //转换坐标 
	} 

function getPositionError(error) {
alert(error.code);
    switch (error.code) {
        case error.TIMEOUT:
            alert("连接超时，请重试");
            break;
        case error.PERMISSION_DENIED:
            alert("您拒绝了使用位置共享服务，查询已取消");
            break;
        case error.POSITION_UNAVAILABLE:
            alert("获取位置信息失败");
            break;
    }
}
	function initMap(p)
	{
		//初始化地图 
		map = new BMap.Map("container");
		map.addControl(new BMap.NavigationControl()); 
		map.addControl(new BMap.ScaleControl()); 
		map.addControl(new BMap.OverviewMapControl()); 
		//MapTypeControl：地图类型控件，默认位于地图右上方。
		map.addControl(new BMap.MapTypeControl());
		map.centerAndZoom(p, 19); 
		//map.addOverlay(new BMap.Marker(p));
		point = p;
	};
</script> 
{/literal}
<script src="__JS__/front/bbc.districtdata.js?version={$version}"></script>
{/block}
